layui.use(['jquery','layer','form','table','laydate','upload'],function(){
    var $ = layui.$,layer = layui.layer,form = layui.form,table = layui.table,laydate = layui.laydate,upload = layui.upload;

    //获取用户解封记录 22/1/12 赵
    getUsers();
    function getUsers(userId){
        $.ajax({
            url: '/user/getUnsealRecord'
            ,data: {'userId': userId,'type': 1}
            ,dataType: 'json'
            ,success:function(data){
                //渲染表格
                tableRender(data.data);
            }
        });
    }
    //渲染表格 22/1/12 赵
    function tableRender(data){
        table.render({
            elem: '#layuiTbale'
            ,data: data
            ,toolbar: '#toolutil'
            ,page: {
                layout: ['count', 'prev', 'page', 'next', 'limit', 'refresh', 'skip']//自定义分页布局
                ,limits:[10,15,20]
                ,first: true
                ,last: true
            }
            ,limit: 10
            ,cols: [[
                {checkbox: true}
                ,{type: 'numbers',title: '序号',align: 'center'}
                ,{field: 'userId',title: '用户编号',align: 'center'}
                ,{field: 'nickname',title: '用户昵称',align: 'center'}
                ,{field: 'startDate',title: '封停时间',align: 'center'}
                ,{field: 'reason',title: '封停原因',align: 'center'}
                ,{field: 'remarks',title: '解封方式',align: 'center'}
                ,{title: '操作',align: 'center',templet:function(data){
                        return '<a onclick="delUnsealRecord('+data.id+')" style="color: #009688;">删除</a> '
                    }}
            ]]
        });
    }

    //删除记录 22/1/12
    delUnsealRecord = function delUnsealRecord(id){
        layer.open({
            title: '删除封禁记录'
            ,content: '是否删除此记录'
            ,area: ['200px','200px']
            ,btn: ['确定','取消']
            ,yes:function(index){
                $.ajax({
                    url: '/user/delUnsealRecord'
                    ,data: {'id': id}
                    ,dataType: 'json'
                    ,success:function(data){
                        layer.close(index);
                        getUsers();
                        layer.msg('已删除');
                    }
                });
            }
            ,btn2:function(index){
                layer.close(index);
            }
        });

    }

    //普同检索 22/1/12
    form.on('submit(sub)',function(data){
        console.log(data);
        $.ajax({
            url: '/user/getUnsealRecord'
            ,data: {
                'account': data.field.account
                ,'nickname': data.field.nickname
                ,'unsealDate': data.field.unsealDate
                ,'type': 1
            }
            ,dataType: 'json'
            ,success:function(data){
                tableRender(data.data);
            }
        });
    });


    //刷新 22/1/12 赵
    refresh = function refresh(){
        location.reload();
    }

    //返回
});
//返回首页
function backOff(){
    parent.jumpSystemHome();
}